package barney.davis.hume.it3048todo;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

import barney.davis.hume.it3048todo.constants.TaskRepeat;
import barney.davis.hume.it3048todo.constants.TaskStatus;
import barney.davis.hume.it3048todo.dao.ITaskDAO;
import barney.davis.hume.it3048todo.dao.TaskDAO;
import barney.davis.hume.it3048todo.dto.Task;
import barney.davis.hume.it3048todo.service.ITaskService;
import barney.davis.hume.it3048todo.service.TaskService;
import android.app.Activity;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.Looper;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;

/**
 * @author Tony
 *
 */
public class ReviewActivity extends Activity {
	
	
	@Override
    protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.review);
            
            List<Task> tasks = new ArrayList<Task>();
            
            ITaskService taskService = new TaskService(this);
            
            //Pull in all tasks of previous 7 days
            Calendar startDate = Calendar.getInstance();
            startDate.add(Calendar.DAY_OF_MONTH, -7);
            
			Calendar endDate = Calendar.getInstance();
			try {
				tasks = taskService.getTasks(startDate , endDate);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
			double complexTotal = 0;
			
			// add complexity value of completed tasks only
			for (int i = 0; i < tasks.size(); i++) {
				if(tasks.get(i).status == TaskStatus.COMPLETE)
				{
					complexTotal += tasks.get(i).complexity;
				}
			}
			
			TextView valueVelocity = (TextView) findViewById(R.id.valueVelocity);
			valueVelocity.setText(String.valueOf(complexTotal));
    }
}
